<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false" %>
<%@ page import="com.atozsoft.commonutil.Constants"%>
<%@ page import="java.math.BigDecimal"%>
<%@ page import="com.eos.data.datacontext.UserObject" %>
<%@ page import="org.gocom.components.coframe.rights.dataset.CapUser"%>	

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- 
  - Author(s): houfy
  - Date: 2016-10-25 11:03:52
  - Description:
-->
<head>
	<%@include file="/common.jsp"%>
	<%@include file="/common/common.jsp"%>
    <%@include file="/coframe/tools/skins/common.jsp"%>
	<title>项目鉴定管理一览</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
	<div class="search-condition">
	<a href="#" class="searchclose"></a>
		<div class="list">
        	<div id="queryappraisalForm">
	        	<table style="width:100%;" class="table">
	            	<tr>
	              		<td class="tit" style="width:120px">
	              			成果归属项目名称：
	              		</td>
	              		<td>
	                		<input id="projectname" class="nui-textbox " onEnter='onKeyEnter' name="criteria._expr[0].projectname" style="width:100%"/>
	                		<input class="nui-hidden" name="criteria._expr[0]._op" value="like"/>
                        	<input class="nui-hidden" name="criteria._expr[0]._likeRule" value="all"/>
	              		</td>
	              		<td class="tit" style="width:120px">
                   			项目编号：
	              		</td>
	              		<td>
	                		<input id="projectfilecode" class="nui-textbox" onEnter='onKeyEnter' name="criteria._expr[1].projectfilecode" style="width:100%"/>
	                		<input class="nui-hidden" name="criteria._expr[1]._op" value="like"/>
                        	<input class="nui-hidden" name="criteria._expr[1]._likeRule" value="all"/>
	              		</td>
		              	<td class="tit" style="width:120px">
                   			成果完成年度：
	              		</td>
	              		<td>
	                		<input id="resultdoneyear" class="nui-textbox" style="width:100%;" onEnter='onKeyEnter' name="criteria._expr[2].resultdoneyear"/>
	                		<input class="nui-hidden" name="criteria._expr[2]._op" value="="/>
	              		</td>
	              		
	              		<td width="20px"></td>
	            	</tr>
          		    <tr>
          		    	<td class="tit" style="width:120px">
                   			项目实施单位：
	              		</td>
	              		<td>
	                		<input id="bidwinner" class="nui-textbox" onEnter='onKeyEnter' name="criteria._expr[3].bidwinner" style="width:100%"/>
	                		<input class="nui-hidden" name="criteria._expr[3]._op" value="like"/>
                        	<input class="nui-hidden" name="criteria._expr[3]._likeRule" value="all"/>
	              		</td>
	            	    <td class="tit">
	              			成果完成单位：
	              		</td>
	              		<td>
	                		<input id="resultdoneunit" class="nui-textbox" onEnter='onKeyEnter' name="criteria._expr[4].resultdoneunit" style="width:100%"/>
	                		<input class="nui-hidden" name="criteria._expr[4]._op" value="like"/>
                        	<input class="nui-hidden" name="criteria._expr[4]._likeRule" value="all"/>
	              		</td>
	              		<td class="tit">
                   			项目主管：
	              		</td>
	              		<td>
	                		<input id="projectleader" class="nui-buttonedit" onEnter='onKeyEnter' name="criteria._expr[5].projectleader" style="width:100%" onbuttonclick="userData1" allowInput="false"/>
	                		<input class="nui-hidden" name="criteria._expr[5]._op" value="="/>
	              		</td>
	              		
	              		<td width="20px"></td>
	            	</tr>
	            	<tr>
	            		<td class="tit">
                   			业务主管部门：
	              		</td>
	              		<td>
	                		<input  id="departmentid" class="nui-treeselect nui-form-input" name="criteria._expr[6].departmentid" 
				       			url="com.shendong.mis.common.queryOrgOrganization.biz.ext" multiSelect="false"  valueFromSelect="false"
	        					dataField="datas" textField="orgname" valueField="orgid" parentField="parentorgid"   allowInput="false"
	       						showRadioButton="true" showFolderCheckBox="false" onbeforenodeselect="beforenodeselect" onEnter='onKeyEnter'/>
	       					<input class="nui-hidden" name="criteria._expr[6]._op" value="="/>
	              		</td>
	            	    <td class="tit">
                   			数据状态：
	              		</td>
	              		<td>
	                		<input id="status" class="nui-dictcombobox nui-form-input" name="criteria._expr[7].status" onEnter='onKeyEnter' showNullItem="true" dictTypeId="PROCESS_STATUS_TYPE"/>
	                		<input class="nui-hidden" name="criteria._expr[7]._op" value="="/>
	              		</td>
	              		<td class="tit">
	              		</td>
	              		<td>
	                		</td>
	              		<td width="20px"></td>
	            	</tr>
          		</table>
          		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="search-btn-area">
					  <tr>
					     <td>
					      	<a class="nui-button" iconCls="icon-search" onclick="search">查询</a>&nbsp;&nbsp;
					      	<a class="nui-button" iconCls="icon-reload" onclick="clear">清空</a>
					     </td>
					  </tr>
		        </table>
        	</div>
      	</div>
    </div>
	<div style="padding:10px 0px 0px 0px;">
		<div class="nui-toolbar" style="border-bottom:0;">
        	<table style="width:100%;">
            	<tr>
		            <td style="width:100%;">
		                <a class="nui-button" iconCls="icon-add" onclick="add()">增加</a>
		            	<a class="nui-button" iconCls="icon-edit" onclick="edit()" id="edit_btn">编辑</a>
		            	<a class="nui-button" iconCls="icon-remove" onclick="remove()" id="delete_btn">删除</a>
		            </td>
	            </tr>
	        </table>
    	</div>
    </div>
    <div class="nui-fit">
  		<div id="appraisalDataGrid" class="nui-datagrid" style="width:100%;height:100%;"
  		 url="com.shendong.mis.projectAppraisal.queryProjectAppraisal.biz.ext" dataField="appraisals"
          	sizeList=[10,20,50,100] multiSelect="true" pageSize="20" allowAlternating="true" onselectionchanged="selectionChanged">
        	<div property="columns">
        		<div field="appraisalid" visible="false">ID</div>
          		<div type="checkcolumn" headerAlign="center" align="center">
          		</div>
          		<div field="theme" allowSort="true" headerAlign="center" renderer="urlRenderer" width="150px">
        			成果名称
          		</div>
          		<div field="resulttype" allowSort="true" headerAlign="center" renderer="onRender">
        			成果形式
          		</div>
          		<div field="resultdoneunit" allowSort="true" headerAlign="center" >
        			成果完成单位
          		</div>
          		<div field="confidentiallevel" allowSort="true" headerAlign="center" renderer="onRender">
        			成果密级
          		</div>
          		<div field="projectname" allowSort="true" headerAlign="center" width="120px">
        			成果归属项目名称
          		</div>
          		<div field="projectfilecode" allowSort="true" headerAlign="center" >
        			项目编号
          		</div>
          		
          		<div field="startdate" allowSort="true" headerAlign="center" align="center" dateFormat="yyyy-MM-dd">
            		开始日期
          		</div> 
          		<div field="enddate" allowSort="true" headerAlign="center" align="center" dateFormat="yyyy-MM-dd">
            		完成日期
          		</div> 
          		<div field="resultdoneyear" allowSort="true" headerAlign="center" >
        			成果完成年度
          		</div>
          		<div field="bidwinner" allowSort="true" headerAlign="center" >
        			项目实施单位
          		</div>
          		<div field="technologyfield1" allowSort="true" headerAlign="center" renderer="onRender">
        			所属技术领域
          		</div>
          		<div field="projectleadername" allowSort="true" headerAlign="center" >
        			项目主管
          		</div>
          		<div field="departmentname" allowSort="true" headerAlign="center" width="120px">
        			业务主管部门
          		</div>
          		<div field="applicationcheckupdate" allowSort="true" headerAlign="center" >
        			申请鉴定日期
          		</div>
          		<div field="applicationunitname" allowSort="true" headerAlign="center" width="120px">
        			申请鉴定单位
          		</div>
          		<div field="status" allowSort="true" headerAlign="center" align="center" renderer="onRender">
            		数据状态
          		</div> 
          		<div field="creatername" allowSort="true" headerAlign="center" visible="false">
            		创建者
          		</div>
          		<div field="createdate" allowSort="true" headerAlign="center" align="center" dateFormat="yyyy-MM-dd" visible="false">
            		创建日期
          		</div> 
          		<div field="processinstid" visible="false">流程实例ID</div>
        	</div>
      	</div>
    </div>
    <script>
    //数据渲染处理
    	function onRender(e){
    		if(e.field=="resulttype"){
    			return nui.getDictText("MIS_RESULTTYPE",e.value);
    		}else if(e.field=="confidentiallevel"){
    			return nui.getDictText("MIS_CONFIDENTIALLEVEL",e.value);
    		}else if(e.field=="technologyfield1"){
    			return nui.getDictText("MIS_TECHNOLOGYFIELD",e.value);
    		}else if (this.field=="status"){
        	    if(e.row.status == "2"){
        	    	dictText = "<a href='#' onclick='showWFgraph("+e.row.processinstid+");'>已审核</a>";
        	    }else if(e.row.status == "1"){
        	    	dictText = "<a href='#' onclick='showWFgraph("+e.row.processinstid+");'>审核中</a>";
        	    }else{
	        	    if(e.row.processinstid != "" && e.row.processinstid != null){
	        	    	dictText = "<a href='#' onclick='showWFgraph("+e.row.processinstid+");'>保存</a>";
	        	    }else{
	        	    	dictText = "保存";
	        	    }
        	    }
        		return dictText;
    		}
    	}
    	// 一览行数据字典显示相关
  		function itname(e)
  		{
        	var dictText="";
      		// 数据状态
        	if (this.field=="status"){
        	    if(e.row.status == "2"){
        	    	dictText = "<a href='#' onclick='showWFgraph("+e.row.processinstid+");'>已审批</a>";
        	    }else if(e.row.status == "1"){
        	    	dictText = "<a href='#' onclick='showWFgraph("+e.row.processinstid+");'>审批中</a>";
        	    }else{
	        	    if(e.row.processinstid != "" && e.row.processinstid != null){
	        	    	dictText = "<a href='#' onclick='showWFgraph("+e.row.processinstid+");'>保存</a>";
	        	    }else{
	        	    	dictText = "保存";
	        	    }
        	    }
        		return dictText;
    		}
      	}
      	
      	function showWFgraph(processInstId){
	    	var zoomvalue = 1;
	    	nui.open({
	            url: "<%=request.getContextPath()%>/wf/processOperate/process_Approve.jsp?processInstId=" + processInstId + "&zoomvalue=" + zoomvalue,
		        title: "查看审批进度",
				width: 700, 
		        height: 635,
		        onload: function() {
		        },
		        ondestroy: function (action) {
					
	             }
		    });
      	}
      	
      	// 清空查询条件
	   function clear(){
			var form = new nui.Form("#queryappraisalForm");
			form.reset();
		}
    </script>
	<script type="text/javascript">
    	nui.parse();
    	var grid=nui.get("appraisalDataGrid");
    	grid.load();
    	grid.sortBy("createdate", "desc");
    	
    	//跳转方式修改为弹出TAB
    	var postUrl="<%=request.getContextPath()%>/mis/common/postUrl.jsp?";

  		// 查询按钮
  		function search(){
			var form=new nui.Form("queryappraisalForm");
			var data=form.getData();
			grid.load(data);
  		}
  		
  		// 回车执行查询
  		function onKeyEnter(e) {
    		search();
  		}
  		
  		// 增加按钮
  		function add() {
  			// 增加按钮
        	var actionFlg = "add";
        	var appraisalId = "";
        	var workitemid = "";
        	var processInstId = "";
        	addDetailTab(actionFlg,appraisalId,processInstId,workitemid, "项目鉴定新增");  
        }
        
        // 修改按钮
        function edit() {
            var row = grid.getSelected();
            if (row) {
	  			onUrl("update",row.appraisalid,row.processinstid,row.workitemid,"项目鉴定修改");
            } else {
                nui.alert("请选中一条记录！","提示");
            }
        }
        // 跳转页面
     	function onUrl(actionFlg,appraisalId,processInstId,workitemid,title){ 
			// 跳转页面并传参（post）      
			addDetailTab(actionFlg,appraisalId,processInstId,workitemid,title);		 
		}
		
		/*
		* 重新打开一个tab页显示详细页面
		* actionFlg: 操作类型
		* guaranteeletterId: ID
		*/
      	function addDetailTab(actionFlg,appraisalId,processInstId,workitemid,title){
      		var url ="<%=request.getContextPath()%>/mis/projectAppraisal/projectAppraisal_detail.jsp"; 
      		
			var params=nui.encode({actionFlg:actionFlg,appraisalId:appraisalId,processInstId:processInstId,workitemid:workitemid});
			var tabName = "appraisal_menu";
			if(appraisalId != null && appraisalId != ""){
				tabName = tabName + "_" +appraisalId;
			}
			window.parent.addtabs(postUrl+"url="+url+"&params="+encodeURIComponent(params),title, tabName); 
      	} 
        
        // 数据链接跳转相关
      	function urlRenderer(e) 
      	{	
      		return "<a class='viewbutton' href='javascript:void()' onclick=onUrl('view','"+e.row.appraisalid+"','"+e.row.processinstid+"','','项目鉴定明细')>"+e.row.theme+"</a>";
     	}
        
        // 删除按钮
        function remove() {
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
            	nui.confirm("确认删除勾选项目鉴定信息？","删除确认",function(action){
	            	if(action!="ok") return;
	  				var json = nui.encode({appraisals:rows});
	                $.ajax({
	                    url: "com.shendong.mis.projectAppraisal.deleteProjectAppraisal.biz.ext",
		                type: 'POST',
		                data: json,
		                cache: false,
		                contentType:'text/json',
	                    success: function (text) {
	                    	var returnJson = nui.decode(text);
							if(returnJson.resultStr == 'SUCCESS'){
								nui.alert("项目鉴定删除成功！", "提示");
	                        }
	                        else{
	                        	nui.alert("项目鉴定删除失败！", "提示");
                        	}
                        	grid.reload();
	                    },
	                    error: function () {
	                    	nui.alert("项目鉴定删除异常！", "提示");
	                    }
	                });
                }); 
            } else {
                nui.alert("请选中一条记录！","提示");
            }
        }
  		
  		// 列表选中行时，根据权限设置编辑删除按钮
        function selectionChanged(){
			// 默认可编辑
			nui.get("edit_btn").enable();
			nui.get("delete_btn").enable();
			
			var row = grid.getSelected();
			// 列表选中多条记录时，编辑按钮不可用
			var rows = grid.getSelecteds();
			if(rows.length>1){
				nui.get("edit_btn").disable();
			}else{
				nui.get("edit_btn").enable();
			}
			// 判断是否选择
			if(row){
				if(row.status == "0")
				{ 
					// 存在则不能编辑
					nui.get("edit_btn").enable();
					nui.get("delete_btn").enable();
				}else
				{
				   nui.get("edit_btn").disable();
				   nui.get("delete_btn").disable();
				}
			}
		}
		
		//各种监听事件
        $(document).ready(
			function(){
			   //收起查询窗口
			   $(".search-condition .searchclose").click(function(){
			  		$(".search-condition .list").toggle();
					setTimeout("nui.layout()", 10 );
			   });
			}
		);
  		
  		// 结束日期不能小于开始日期检查
		function onDateValidation(e)
		{
			if (e.isValid) {
				var startDate = nui.get("startDate").getValue();
				var endDate = nui.get("endDate").getValue();
				if(startDate != null && startDate != "" && endDate != null && endDate != ""){
	                if (startDate > endDate) {
	                    e.errorText = "结束日期不能小于开始日期！";
	                    e.isValid = false;
	                }
	                else{
	                	nui.get("startDate").setIsValid(true);
	                	nui.get("endDate").setIsValid(true);
	                }
                }
            }
		}
		//项目主管的点击函数
        function userData1(){
	    	nui.open({
                url: "<%=request.getContextPath()%>/mis/orgUser/selectEmployee.jsp",
                title: "用户",
                width: 870,
                height: 550,
                onload: function () {
                	var iframe = this.getIFrameEl();
			        iframe.contentWindow.SetData({multiSelect:'false'});
                },
                ondestroy: function (action) {
              	 	if(action=="ok"){
              	 		var iframe = this.getIFrameEl();
                        var data = iframe.contentWindow.GetData();
                        data = nui.clone(data);    //必须克隆返回值
                       /*  alert(nui.encode(data)); */
                        // 主管所领导赋值
                        nui.get("projectleader").setValue(data.empid);
                        nui.get("projectleader").setText(data.username); 
                    }
                }
            });
	    }
	     //写完treeSelect必须加这个函数，要不选不到
    	function beforenodeselect(e) {
            //禁止选中父节点
            if (e.isLeaf == false) e.cancel = true;
        }
    </script>
</body>
</html>